/*
 * @Author: fangzhi 
 * @Date: 2018-04-18 16:08:11 
 * @Last Modified by: fangzhi
 * @Last Modified time: 2018-06-04 11:03:46
 */

// Vue 入口
import Vue from 'vue';
import Vuex from "vuex";
import App from './App';
import router from './router';
// element UI 
import ElementUI from "element-ui";
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI, { size: "small" });
// 国际化
import i18n from "./components/common/lang/index";

// Vuex
import store from "./vuex/index";

// 全局样式
import "@/components/common/css/global.css"
import "@/components/common/css/reset.css"

// 配置http和tool 
import axios from "./utils/http";
import tools from "./utils/tools";
Vue.prototype.$Http = axios;
Vue.prototype.$Tools = tools;

Vue.config.productionTip = false;

// 全局导航钩子 判断用户登陆信息
router.beforeEach((to, from, next) => {
  let grade = sessionStorage.getItem(2);
  if (to.meta.requireAuth) {
    if (grade !== null) {
      next();
    } else {
      router.replace({ name: "login" })
    }
  } else {
    next();
  }
})

/* eslint-disable no-new */
window.app = new Vue({
  el: '#app',
  router,
  i18n,
  store,
  components: { App },
  template: '<App/>'
})

